package com.gs.wzmanager.controller;

import com.gs.wzmanager.entity.Port;
import com.gs.wzmanager.service.PortService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "port")
public class PortController {
    private Logger logger = LoggerFactory.getLogger(LoginController.class);

    @Autowired
    PortService portService;

    @RequestMapping(value = "listView")
    public String view(){
        return "port/list";
    }

    @RequestMapping(value = "queryAll")
    @ResponseBody
    public List<Port> queryAllPort() {
        return portService.queryAllPort();
    }

    @RequestMapping(value = "update", method = RequestMethod.POST)
    public ResponseEntity updatePort(@RequestBody Port port) {
        logger.info("updatePort->{}", port);
        return portService.update(port);
    }

    @RequestMapping(value = "add", method = RequestMethod.POST)
    public ResponseEntity addPort(@RequestBody Port port) {
        logger.info("addPort->{}", port);
        return portService.addPort(port);
    }

}
